
#pragma once

#include <ConnectionBroker/clientconnection/ClientConnection.h>
#include <ConnectionBroker/TcpConnection.h>
#include <ConnectionBroker/TcpMessage.h>
#include <ConnectionBroker/Typedefs.h>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/cstdint.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>

namespace ConnectionBroker
{
   class TcpServer;
   class TcpClientConnection : public ClientConnection,
                               public TcpConnection
   {
      protected: //Member variables
      TcpServer* mServer;

      public: //Constructor, destructor
      TcpClientConnection(boost::asio::io_service& pIoService, TcpServer* pServer, boost::shared_ptr<boost::asio::ssl::context> pContext = boost::shared_ptr<boost::asio::ssl::context>());
      virtual ~TcpClientConnection();

      public: //Required Overrides
      virtual void write(const Packet& p);

      protected: //Required Overrides
      virtual void messageReceived(const Packet& pMessage);

      protected: //Overrides
      virtual void onStop();
      virtual void connectionEstablished();

      protected: //Shared From This

      TcpClientConnectionPtr sharedFromThis()
      {
         return boost::static_pointer_cast<TcpClientConnection>(shared_from_this());
      }
   }; 


}

